<template>
  <picker
    @change="pickerChange"
    @columnchange="columnChange"
    :value="index"
    :range="shop_list"
    range-key="name"
    ><slot></slot
  ></picker>
</template>

<script>
export default {
  data() {
    return {
      shop_list: [],
      index: 0,
      pageSize: 999,
    };
  },
  created() {
    this.getAllShop();
  },
  methods: {
    //  获取列表
    async getAllShop() {
      const { err, data } = await this.$u.api.getAllShop({
        page: 1,
        pageSize: this.pageSize,
      });
      if (err) return;
      this.shop_list = data;
      this.shop_list.unshift({
        id: 0,
        name: "全部",
      });
    },
    pickerChange(e) {
      const row = this.shop_list[e.detail.value];
      this.$emit("pickerChange", row, e);
    },
    columnChange(e) {
      this.index = e.detail.value;
    },
  },
};
</script>

<style></style>
